package de.uni.muenster.idw2.view;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.util.AttributeSet;
import android.view.View;
import de.uni.muenster.idw2.data.Position;
import de.uni.muenster.idw2.utilities.Utils;

public class BuildingMapView extends View{
	
	private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
		
		@Override
		public void onReceive(Context context, Intent intent) {
			if(intent.getAction().equals(Utils.RECEIVER_MSG)){
				Position posUpdate = (Position) intent.getExtras().getParcelable(Utils.LOCATION_UPDATE);
				// DO BLAH BLAH... map update usw... (your map update)
			}
		}
	};
	
	public BuildingMapView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		init();
	}

	public BuildingMapView(Context context, AttributeSet attrs) {
		super(context, attrs);
		init();
	}

	public BuildingMapView(Context context) {
		super(context);
		init();
	}
	
	private void init(){
		
	}
	
	public void enableReceiver(Activity act){
		IntentFilter inetnetFilter =  new IntentFilter(Utils.RECEIVER_MSG);
		act.registerReceiver(broadcastReceiver, inetnetFilter);
	}
	
	public void disableReceiver(Activity act){
		act.unregisterReceiver(broadcastReceiver);
	}
}
